<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>

    </ul>
    <button id="load-more">加载更多</button>
    <script>
        /*
       localStorage.setItem('name','lily')
       c
       const goodsStr = JSON.stringify(goods)
       localStorage.setItem('goods',goodsStr)

       const str = localStorage.getItem('goods')
       const data = JSON.parse(str)
        */
       function setStorage(key,data){
           const dataStr = JSON.stringify(data)
           localStorage.setItem(key,dataStr)
       }

       function getStorage(key){
           const dataStr = localStorage.getItem(key)
           let data
            try{
                data = JSON.parse(dataStr)
            }catch (e){
                return dataStr
            }
           return data
       }
       const goods = {iid:'123',price:256}

       setStorage('goods',goods)

    </script>

</body>

</html>